<ion-view view-title={{moduleTitle}}>
    <ion-nav-buttons side="left">
        <a class="button button-icon ion-arrow-left-c" ng-click="goBack()"></a>
    </ion-nav-buttons>
    <ion-side-menus>

        <div class="tabs-striped tabs-top">
            <div class="tabs">
                <a ng-if="access.list" ng-class="{'tab-item':true,'active': id }" href="#/{{moduleName}}/list">查看</a>
                <a ng-if="access.add" ng-class="{'tab-item':true,'active': !id }" href="#/{{moduleName}}/0">添加</a>
            </div>
        </div>
        <ion-side-menu-content class="padding has-tabs-top">
            <ion-content class="padding has-tabs-top">
                <form name="detailForm" novalidate="" ng-submit="submitForm(detailForm)">
                    <ion-list class="list">
                        <a class="item item-icon-right" menu-toggle="{{farmerInfo.menu_toggle}}">
                            农户<span style="color:red">*</span>&nbsp&nbsp{{farmerInfo.selected_farmer}}
                            <i ng-show="!farmerInfo.is_farmer" class="icon ion-ios-arrow-right"></i>
                        </a>
                        <label ng-show="false" class="item item-input">
                            <span class="input-label">农户ID：</span>
                            <input type="text" name="farmer_id" ng-model="farmerInfo.farmer_id"
                                   required
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.farmer_id.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>

                        <label class="item item-input">
                            <span class="input-label">播种日期</span>
                        </label>
                        <insert-date form="detailForm" dateoption="sowDateOption"></insert-date>
                        <label class="item item-input">
                            <span class="input-label">收获日期</span>
                        </label>
                        <insert-date form="detailForm" dateoption="harvestDateOption"></insert-date>
                        <insert-select form="detailForm" option="plantOption"></insert-select>

                        <label class="item item-input">
                            <span class="input-label">种植面积：</span>
                            <input type="text" name="plant_area" ng-model="detail.plant_area"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.plant_area.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>


                        <label class="item item-input">
                            <span class="input-label">株距(厘米)：</span>
                            <input type="text" name="plant_space" ng-model="detail.plant_space"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.plant_space.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">行距(厘米)：</span>
                            <input type="text" name="row_space" ng-model="detail.row_space"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.row_space.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">种子类型：</span>
                            <input type="text" name="seed" ng-model="detail.seed"
                                   ng-maxlength="20"
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.seed.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-maxlength-20.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">灌溉方式：</span>
                            <input type="text" name="irrigation" ng-model="detail.irrigation"
                                   ng-maxlength="10"
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.irrigation.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-maxlength-10.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">种子开销（元/亩）：</span>
                            <input type="text" name="seed_cost" ng-model="detail.seed_cost"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.seed_cost.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">肥料开销（元/亩）：</span>
                            <input type="text" name="fertilizer_cost" ng-model="detail.fertilizer_cost"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.fertilizer_cost.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">农药开销（元/亩）：</span>
                            <input type="text" name="pesticide_cost" ng-model="detail.pesticide_cost"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.pesticide_cost.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">农机开销（元/亩）：</span>
                            <input type="text" name="machinery_cost" ng-model="detail.machinery_cost"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.machinery_cost.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">其他开销（元/亩）：</span>
                            <input type="text" name="others_cost" ng-model="detail.others_cost"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.others_cost.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">一般产量（千克/亩）：</span>
                            <input type="text" name="general_yield" ng-model="detail.general_yield"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.general_yield.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>
                        <label class="item item-input">
                            <span class="input-label">其他收益（元/亩）：</span>
                            <input type="text" name="other_yield" ng-model="detail.other_yield"
                                   ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.other_yield.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                        </div>


                        <label class="item item-input">
                            <span class="input-label">备注：</span>
                            <input type="text" name="comments" ng-model="detail.comments"
                                   ng-maxlength="50"
                                   ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                        </label>

                        <a class="item item-icon-left " ng-click="openFertilizerPopover($event)">
                            添加施肥推荐信息
                            <i class="icon ion-plus-circled"></i>
                        </a>
                        <ion-item ng-repeat="item in subFertilizerList | orderObjectById:'id':true">
                            <h2>{{item.fertilization_date}}</h2>
                            <p>施肥类型:{{ item.type }};化肥：{{ item.fertilizer_name }}</p>
                            <p>施肥数量（千克/亩）:{{ item.fertilizer_quantity }}</p>
                            <p>施肥方法:{{ item.fertilization_method }}</p>
                            <ion-option-button class="ion-minus-circled"
                                               ng-click="onItemDelete(item,$index,'fertilization_info')">
                            </ion-option-button>
                        </ion-item>
                        <!-- Error Container for Password -->
                        <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                             ng-messages="detailForm.comments.$error" role="alert">
                            <div ng-messages-include="templates/system-templates/detail-maxlength-50.html"></div>
                        </div>


                    </ion-list>
                    <button class="button button-full button-positive" ng-disabled="detailForm.$invalid || detailEdit.editDisabled" type="submit">
                        {{operation}}
                    </button>
                </form>
            </ion-content>
        </ion-side-menu-content>
        <ion-side-menu expose-aside-when="large" side="right">
            <ion-content class="has-tabs-top padding">

                <div class="item item-divider text-center">
                    <a>选择农户</a>
                </div>

                <insert-address  addressoption="farmerAddressOption"></insert-address>
                <label class="item item-input">
                    <span class="input-label">农户姓名：</span>
                    <input type="text" ng-model="farmerInfo.farmer_name">
                </label>
                <!--<label class="item item-input">-->
                <!--<span class="input-label">手机号：</span>-->
                <!--<input type="text" ng-model="farmerInfo.cell">-->
                <!--</label>-->
                <!--<ion-content>-->
                <button class="button button-full button-positive" ng-click="filterFarmer()">查询</button>

                <div class="item item-divider text-center">
                    <a>农户列表</a>
                </div>

                <ion-list class="list" >
                    <ion-item menu-close ng-repeat="item in chooseFarmerList | orderObjectById:'farmer_id':true"
                              ng-click="setFarmer(item.farmer_id,item.farmer_name)">
                        <h2>{{item.province+item.city+item.county+item.town+item.village}}</h2>
                        <p>农户：{{ item.farmer_name }}</p>
                        <p>手机号：{{ item.cell }}</p>
                    </ion-item>

                    <div ng-if="listEnd" class="text-center">
                        已显示所有数据
                    </div>
                </ion-list>
                <ion-infinite-scroll ng-if="!listEnd" on-infinite="loadList(false)" distance="1%"></ion-infinite-scroll>

            </ion-content>
        </ion-side-menu>
    </ion-side-menus>
    <!--头部和内容结束-->
</ion-view>